﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using ASPPanificadora.fabrica;
using ASPPanificadora.classes;
using NHibernate;

namespace WCFPanificadora.servicos
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "CargoS" in code, svc and config file together.
    public class CargoS : ICargoS
    {
        Fabrica fabrica = new Fabrica();
        public string Salvar(Cargo cargo)
        {
            return fabrica.Salva(cargo);
        }

        public IList<Cargo> Recuperar()
        {
            ISession sessao = fabrica.sessao();
            IList<Cargo> cargo = sessao.CreateCriteria<Cargo>().List<Cargo>();
            return cargo;
        }


        public Cargo PesquisarPorId(int id)
        {
            ISession sessao = fabrica.sessao();
            Cargo cargo = sessao.Get<Cargo>(id);
            return cargo;
        }
    }
}
